package com.example.chat.controller;


import com.example.chat.pojo.dto.UserDTO;
import com.example.chat.pojo.bo.User;
import com.example.chat.pojo.res.ResModel;
import com.example.chat.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 林邵晨
 * @since 2023-07-24
 */
@RestController
@RequestMapping("/chat/user")
public class UserController {

    @Resource
    private UserService userService;


    @ApiOperation("注册")
    @PostMapping(path = "/register",produces = "application/json")
    public ResModel register(@RequestBody UserDTO user){
        return userService.register(user);
    }

    @ApiOperation("登录")
    @PostMapping(path = "/login",produces = "application/json")
    public ResModel login(@RequestBody UserDTO user){
        return userService.login(user);
    }

    @ApiOperation("查询用户信息")
    @GetMapping(path = "/profile/{cid}",produces = "application/json")
    public ResModel getProfile(@PathVariable String cid){
        return userService.getProfile(cid);
    }

    @ApiOperation("修改用户信息")
    @PutMapping(path = "/profile",produces = "application/json")
    public ResModel updateProfile(@RequestBody User user){
        return userService.updateProfile(user);
    }

}

